{template '_header'}

<div class="page-heading"> <h2><i class="fa fa-circle-o"></i>销售统计</h2><span>按年、月、日统计商城交易额、交易量</span> </div>
     <form action="./index.php" method="get" class="form-horizontal">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="ewei_shopv2" />
            <input type="hidden" name="do" value="web" />
            <input type="hidden" name="r"  value="statistics.sale" />
<div class="page-toolbar row m-b-sm m-t-sm">
                        
	  
			 
                            <div class="col-sm-12">
                                <select name="year" class='form-control input-sm select-sm'>
                        {loop $years $y}
                        <option value="{$y['data']}"  {if $y['selected']}selected="selected"{/if}>{$y['data']}年</option>
                        {/loop}
                    </select>
                    <select name="month" class='form-control input-sm select-sm'>
                        <option value=''>月份</option>
                        {loop $months $m}
                        <option value="{$m['data']}"  {if $m['selected']}selected="selected"{/if}>{$m['data']}月</option>
                        {/loop}
                    </select>
                       <select name="day" class='form-control input-sm select-sm'>
                        <option value=''>日期</option>
                    </select>
                                
                         <select name="type" class='form-control input-sm select-sm'>
                        <option value='0' {if $_GPC['type']==0}selected="selected"{/if}>交易额</option>
                        <option value='1' {if $_GPC['type']==1}selected="selected"{/if}>交易量</option>
                    
                    </select>
                                
			  
                                <div class='btn-group btn-group-sm'>
						
                                     <button class="btn btn-sm btn-primary" type="submit"> 搜索</button>
                                     
                                         {ifp 'statistics.sale.export'}
                    <button style="height: 34px;  border-left:1px solid #fff;  background-color: #2897e4!important;" type="submit" name="export" value='1' class="btn btn-success btn-sm">导出 Excel</button>
                    {/if}
                    </div>
                                
								
                            </div>
</div>
 </form>
 
 
<div class="panel panel-default">
    <div class='panel-heading'>
     
        {if empty($type)}交易额{else}交易量{/if}：<span style="color:red; ">{$totalcount}</span>，
        最高{if empty($type)}交易额{else}交易量{/if}：<span style="color:red; ">{$maxcount}</span> {if !empty($maxcount_date)}<span>({$maxcount_date}</span>){/if}
       
    </div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th style='width:100px;'>
                        {if empty($_GPC['month'])}月份{else}日期{/if}
                    </th>
                    <th style='width:200px;'>{if empty($type)}交易额{else}交易量{/if}</th>
                    <th>所占比例</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['data']}</td>
                    <td>{$row['count']}</td>
                    <td>
                       <div class="progress" style='max-width:500px;' >
                           <div style="width: {$row['percent']}%;" class="progress-bar progress-bar-info" ><span style="color:#000">{php echo empty($row['percent'])?'':$row['percent'].'%'}</span></div>
                       </div>
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>   
    </div>
</div>
<script language='javascript'>
    function get_days(){
          
        var year = $('select[name=year]').val();
        var month =$('select[name=month]').val();
        var day  = $('select[name=day]');
       day.get(0).options.length = 0 ;
        if(month==''){
	   day.append("<option value=''>日期</option");
            return;
        }
       
        day.get(0).options.length = 0 ;
        day.append("<option value=''>...</option").attr('disabled',true);
        $.post("{php echo webUrl('util/days')}",{year:year,month:month},function(days){
             day.get(0).options.length = 0 ;
             day.removeAttr('disabled');
             days =parseInt(days);
             day.append("<option value=''>日期</option");
             for(var i=1;i<=days;i++){
                 day.append("<option value='" + i +"'>" + i + "日</option");
             }
          
             {if !empty($day)}
                day.val( {$day});
             {/if}
        })
    }
    $('select[name=month]').change(function(){
           get_days();
    })
    
    get_days();
 </script>
{template '_footer'}
